Skip to content

Add friends likes#2

Merged
LevshaKS merged 12 commits into
mainfrom
add-friends-likes
May 5, 2025
Merged

Add friends likes#2
LevshaKS merged 12 commits into
mainfrom
add-friends-likes

Conversation

@LevshaKS
Copy link
Copy Markdown
Owner

No description provided.

Copy link
Copy Markdown

@avfyodorov avfyodorov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Добрый день, Константин!

Практически всё сделано, осталось чуть поправить.

private final Map<Long, Film> films = new HashMap<>();
private final Logger log = LoggerFactory.getLogger(FilmController.class);
private final Logger logger = LoggerFactory.getLogger(FilmController.class);
FilmService filmService;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Для соблюдения инкапсуляции переменную лучше сделать приватной.


@GetMapping("/{id}")
@ResponseStatus(HttpStatus.OK)
public Film getFilmId(@PathVariable long id) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PathVariable long id

Здесь и дальше.
К таким параметрам можно было бы добавить аннотацию Positive.
Конечно, на Ваше усмотрение.
Обратите внимание, что необходимо будет добавить @validated в контроллер на уровне класса, чтобы проверять параметры метода. В этом случае аннотация @validated устанавливается на уровне класса, даже если она присутствует на методах.

import java.util.HashSet;
import java.util.Set;

@Component
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Вместо Component можно использовать Repository
Аннотация @repository показывает, что класс применяется для работы с поиском, а также для получения и хранения данных. На практике @repository может применяться при реализации шаблона DAO.
Необязательно, на Ваше усмотрение.

Различие между аннотациями component, @repository и @service в Spring
https://sky.pro/media/razlichie-mezhdu-annotacziyami-component-repository-i-service-v-spring/

public class InMemoryFilmStorage extends Storage<Film> implements FilmStorage<Film> {


public Film create(Film film) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Над методами лучше расставлять аннотацию

Override

Copy link
Copy Markdown

@avfyodorov avfyodorov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Добрый день, Константин!

Замечаний нет.
Работа принята.

@LevshaKS LevshaKS merged commit a35ae52 into main May 5, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants